/**
 * 功能:显示登陆页面,使用易动帐号登陆
 * 创建日期: 2012-03-16
 * 创建人: 全轩
 * 功能修正说明:
 * 		
 */
if(!this.LoginWin)
{
	this.LoginWin = {};
}

(function(){
	//登陆窗体
	if(!LoginWin.win)
	{
		LoginWin.win = {};
	}
	
	//父窗体
	if(!LoginWin.parentwin)
	{
		LoginWin.parentwin = {};
	}
	
	/**
	 * 生成登陆界面
	 */
	if(typeof LoginWin.CreateLoginWin !== 'function')
	{
		LoginWin.CreateLoginWin = function()
		{
			LoginWin.Init();
			
			var baseView = Ti.UI.createTableView({
				borderRadius:10,
				top:'80px',
				left:'20px',
				width:'280px',
				height:'87px',
				scrollable:false,
			});
			
			var rows = [];
			var namerow = Ti.UI.createTableViewRow();
			var lbname = Ti.UI.createLabel({
				text:'用户名',
				color:'#333',
				left:'15px',
			});
			var tbname = Ti.UI.createTextField({
				hintText:'请输入用户名',
				left:'80px',
				width:'190px',
				value:'qx105b@163.com',
				borderStyle:Ti.UI.INPUT_BORDERSTYLE_NONE,
				keyboardType : Titanium.UI.KEYBOARD_EMAIL,    			
			});
			
			tbname.addEventListener('return',function(e){
					LoginHandler.Logon(tbname,tbpwd,function(){
						alert('账号密码不匹配!');
					});
			});
			
			namerow.add(lbname);
			namerow.add(tbname);
			rows.push(namerow);
			
			//输入密码
			var pwdrow = Ti.UI.createTableViewRow();
			var lbpwd = Ti.UI.createLabel({
				text:'密    码',
				left:'15px',
				color:'#333',
			});
			var tbpwd = Ti.UI.createTextField({
				hintText:'请输入密码',
				left:'80px',
				width:'190px',
				value:'quanxuan',
				borderStyle:Ti.UI.INPUT_BORDERSTYLE_NONE,
				returnKeyType : Titanium.UI.RETURNKEY_GO,
				passwordMask:true,
			});
			
			tbpwd.addEventListener('return',function(e){
					LoginHandler.Logon(tbname,tbpwd,function(){
						alert('账号密码不匹配!');
					});
			});
			
			pwdrow.add(lbpwd);
			pwdrow.add(tbpwd);
			rows.push(pwdrow);
			
			baseView.setData(rows);
			LoginWin.win.add(baseView);
			
			var btnLogon = Ti.UI.createButton({
				title:'登陆',
				top:'170px',
				left:'125px',
				width:'70px',
				height:'30px',
			});
			
			btnLogon.addEventListener('click',function(e){
					LoginHandler.Logon(tbname,tbpwd,function(){
						alert('账号密码不匹配!');
					});
			});
			
			var btnRegister = Ti.UI.createButton({
				title:'注册',
				top:'170px',
				left:'217px',
				width:'70px',
				height:'30px',
			});
			LoginWin.win.add(btnLogon);
			LoginWin.win.add(btnRegister);
			
			//按钮,找回密码
			var forgetpwd = Ti.UI.createLabel({
				top:'170px',
				left:'20px',
				height:'30px',
				width:'90px',
				backgroundImage:'images/login_bg2.png',
				text:'忘记密码?'
			});
			
			forgetpwd.addEventListener('click',function(e){
				alert("知道了!等会邮件发送给你!");
			});
			
			LoginWin.win.add(forgetpwd);
			
			return LoginWin.win;
		}
	}
	
	/**
	 * 初始化登陆窗口
	 * 
	 */
	if(typeof LoginWin.Init !== 'function')
	{
		LoginWin.Init = function()
		{
			LoginWin.win = Ti.UI.createWindow({
				backgroundImage:'images/login_bg.png',
				appearance : Titanium.UI.KEYBOARD_APPEARANCE_ALERT, 
    			keyboardType : Titanium.UI.KEYBOARD_EMAIL,
    			returnKeyType : Titanium.UI.RETURNKEY_GO,
			});
		}
	}
	
	/**
	 * 设置父窗体
	 * @param parentWin 父窗体
	 */
	if(typeof LoginWin.SetParentWin !== 'function')
	{
		LoginWin.SetParentWin = function(parentWin)
		{
			if(parentWin)
			{
				LoginWin.parentwin = parentWin;
			}
			else
			{
				Ti.API.log('LoginWin.SetParentWin:发生异常！参数parentWin不能为空!');
			}
			
		}
	}
	
}())

//SinaApp.LoginWin = LoginWin;
